<template>
  <view class="home-container">
    <!-- 服务器状态显示 - 优化版 -->
    <view class="server-status-compact">
      <view class="status-left">
        <view :class="['status-dot', serverStatus]"></view>
        <text class="status-label">{{ statusText }}</text>
      </view>
      <view class="status-right">
        <text v-if="networkInfo" class="network-label">{{ networkInfo }}</text>
        <view class="refresh-icon" @click="refreshServerStatus" :class="{ 'refreshing': isRefreshing }">
          <text class="icon-text">{{ isRefreshing ? '⏳' : '🔄' }}</text>
        </view>
      </view>
    </view>
      
    <!-- 环境信息显示（仅开发环境显示） - 优化版 -->
    <view v-if="showEnvInfo" class="env-info-compact">
      <text class="env-label">🔧 {{ envInfo.environment }} | {{ envInfo.platform }}</text>
    </view>
    
    <!-- 用户信息区域 - 增强版 -->
    <view class="user-info-card" v-if="isLoggedIn">
      <view class="card-background"></view>
      <view class="user-main-info">
        <view class="avatar-wrapper">
          <view class="avatar-ring"></view>
          <image 
            v-if="userAvatar" 
            :src="userAvatar" 
            class="user-avatar-enhanced"
            mode="aspectFill"
            @error="handleAvatarError"
          />
          <view v-else class="default-avatar-enhanced">
            <text class="avatar-text-large">{{ userName ? userName.charAt(0) : 'U' }}</text>
          </view>
        </view>
        <view class="user-details">
          <view class="greeting-row">
            <text class="greeting-title">Hi, {{ userName || '用户' }}! 👋</text>
            <!-- 管理员徽章 -->
            <view v-if="isAdmin" class="admin-badge" @click="navigateToAdmin">
              <text class="badge-icon">👑</text>
              <text class="badge-text">管理员</text>
            </view>
          </view>
          <text class="greeting-subtitle-new">今天也要加油哦 💪</text>
        </view>
      </view>
    </view>
    
    <!-- 公告横幅 -->
    <view class="announcement-section" v-if="announcements.length > 0">
      <view class="announcement-banner">
        <view class="banner-content">
          <text class="banner-icon">📢</text>
          <swiper 
            class="announcement-swiper" 
            :autoplay="true" 
            :interval="6000" 
            :duration="800"
            :circular="true"
            :indicator-dots="false"
          >
            <swiper-item v-for="(announcement, index) in announcements" :key="index">
              <view class="announcement-item" @click="showAnnouncementDetail(announcement)">
                <text class="announcement-text">{{ announcement.title }}</text>
                <text class="announcement-arrow">></text>
              </view>
            </swiper-item>
          </swiper>
        </view>
      </view>
      
      <!-- 自定义指示点 -->
      <view class="announcement-indicators">
        <view 
          v-for="(announcement, index) in announcements" 
          :key="index"
          class="indicator-dot"
          :class="{ 'active': currentAnnouncementIndex === index }"
          @click="switchToAnnouncement(index)"
        ></view>
      </view>
    </view>
    
    <!-- 欢迎内容 -->
    <view class="welcome-content" v-if="!isLoggedIn">
      <view class="welcome-info">
        <text class="welcome-title">欢迎使用</text>
        <text class="welcome-subtitle">请先登录以使用完整功能</text>
      </view>
      <view class="welcome-actions">
        <button class="login-btn" @click="navigateToLogin">登录</button>
        <button class="register-btn" @click="navigateToRegister">注册</button>
      </view>
    </view>
    
    <!-- 功能中心标题（仅已登录时显示） -->
    <view class="function-center-title" v-if="isLoggedIn">
      <text class="title-text">功能中心</text>
      <text class="subtitle-text">选择你想要使用的功能</text>
    </view>
    
    <!-- 功能网格 - 增强版 -->
    <view class="function-grid-enhanced">
      <view class="function-card settings" @click="navigateToSettings">
        <view class="card-gradient gradient-purple"></view>
        <view class="card-content">
          <text class="function-icon-large">⚙️</text>
          <text class="function-name-bold">系统设置</text>
          <text class="function-desc-new">个性化设置</text>
        </view>
      </view>
      
      <view class="function-card sync" @click="openDataSyncModal">
        <view class="card-gradient gradient-blue"></view>
        <view class="card-content">
          <text class="function-icon-large">🔄</text>
          <text class="function-name-bold">数据同步</text>
          <text class="function-desc-new">同步服务器数据</text>
        </view>
      </view>
      
      <view class="function-card logs" @click="navigateToLogs">
        <view class="card-gradient gradient-cyan"></view>
        <view class="card-content">
          <text class="function-icon-large">📄</text>
          <text class="function-name-bold">日志信息</text>
          <text class="function-desc-new">查看请求记录&最近活动记录</text>
        </view>
      </view>
      
      <view class="function-card tts" @click="navigateToTTS">
        <view class="card-gradient gradient-orange"></view>
        <view class="card-content">
          <text class="function-icon-large">🎙️</text>
          <text class="function-name-bold">配音生成</text>
          <text class="function-desc-new">文本转MP3</text>
        </view>
      </view>

      <view class="function-card emoji" @click="navigateToEmoji">
        <view class="card-gradient gradient-pink"></view>
        <view class="card-content">
          <text class="function-icon-large">😄</text>
          <text class="function-name-bold">表情包</text>
          <text class="function-desc-new">搜图与预览</text>
        </view>
      </view>
      
      <view class="function-card pet" @click="navigateToPetSettings">
        <view class="card-gradient gradient-green"></view>
        <view class="card-content">
          <text class="function-icon-large">🐾</text>
          <text class="function-name-bold">桌面宠物</text>
          <text class="function-desc-new">萌宠陪伴</text>
        </view>
      </view>
		</view>
		
		<!-- 数据同步弹窗 -->
		<DataSyncModal 
			:visible="showDataSyncModal"
			@close="closeDataSyncModal"
			@user-data-updated="onUserDataUpdated"
		/>
		
		<!-- 桌面宠物组件 -->
		<DesktopPet 
			v-if="showDesktopPet"
			:pet-data="desktopPetData"
			:visible="desktopPetVisible"
			@pet-data-updated="onPetDataUpdated"
		/>
	</view>
</template>

<script>
import apiService from '../../utils/api-service.js'
import appStateManager from '../../utils/app-state-manager.js'
import config from '../../utils/config.js'
import desktopPetManager from '../../utils/desktop-pet-manager.js'
import chatService from '../../utils/websocket-chat-service.js'
import DataSyncModal from './components/DataSyncModal.vue'
import DesktopPet from '../../components/DesktopPet.vue'

	export default {
		components: {
			DataSyncModal,
			DesktopPet
		},
		data() {
			return {
      isLoggedIn: false,
      userName: '',
      userAvatar: '',
      userRole: '',
      isAdmin: false,
      serverStatus: 'checking', // 初始为检查中
      statusText: '正在检查服务器状态...',
      networkInfo: '',
      isRefreshing: false,
      envInfo: {},
      showEnvInfo: false,
      announcements: [],
      currentAnnouncementIndex: 0,
      
      // 数据同步弹窗状态
      showDataSyncModal: false,
      
      // 桌面宠物相关
      showDesktopPet: false,
      desktopPetVisible: true,
      desktopPetData: {}
    }
  },
  
		onLoad() {
    this.checkLoginStatus()
    // 直接从状态管理器获取当前状态
    const serverState = appStateManager.getState('server')
    this.serverStatus = serverState.isOnline ? 'online' : 'offline'
    this.statusText = serverState.isOnline ? '服务器连接正常' : '服务器连接异常'
    // 只检查一次状态，然后监听变化
    this.setupServerStatusListener()
    // 初始化环境信息
    this.initEnvironmentInfo()
    // 启动公告轮播指示点同步
    this.startAnnouncementSync()
    // 加载公告数据
    this.loadAnnouncements()
    // 初始化桌面宠物
    this.initDesktopPet()
  },
  
  onShow() {
    // 每次页面显示时都检查登录状态，确保状态同步
    this.checkLoginStatus()
    // 检查服务器状态
    // 使用新的状态管理器
    appStateManager.subscribe('server', (serverState) => {
      this.serverOnline = serverState.isOnline
    })
    // 重新加载公告，确保显示最新内容
    this.loadAnnouncements()
  },
  
  onUnload() {
    // 清理资源
    this.cleanup()
  },
  
		methods: {
    checkLoginStatus() {
      try {
        const token = uni.getStorageSync('user_token')
        const currentUser = uni.getStorageSync('currentUser')
        
        // 检查是否有有效的登录数据
        if (token && currentUser) {
          try {
            const userData = JSON.parse(currentUser)
            if (userData && userData.name) {
              this.isLoggedIn = true
              this.userName = userData.name
              this.userAvatar = userData.avatar || ''
              this.userRole = userData.role || 'user'
              this.isAdmin = userData.role === 'admin'
            } else {
              // 数据无效，清除登录状态
              this.clearLoginData()
            }
          } catch (parseError) {
            // JSON解析失败，清除登录状态
            this.clearLoginData()
          }
        } else {
          // 没有登录数据
          this.isLoggedIn = false
          this.userName = ''
        }
      } catch (error) {
        console.log('检查登录状态失败:', error)
        this.clearLoginData()
      }
    },
    
    clearLoginData() {
      this.isLoggedIn = false
      this.userName = ''
      this.userAvatar = ''
      this.userRole = ''
      this.isAdmin = false
      // 清除可能存在的无效数据
      uni.removeStorageSync('user_token')
      uni.removeStorageSync('currentUser')
      uni.removeStorageSync('currentToken')
      uni.removeStorageSync('isServerLogin')
    },
    
    async logout() {
      uni.showModal({
        title: '退出登录',
        content: '确定要退出当前账户吗？',
        success: async (res) => {
          if (res.confirm) {
            try {
              // 先断开WebSocket连接
              try {
                await chatService.disconnect()
                console.log('WebSocket连接已断开')
              } catch (error) {
                console.warn('断开WebSocket连接失败:', error)
              }
              
              // 清除所有用户相关数据
              uni.removeStorageSync('user_token')
              uni.removeStorageSync('currentUser')
              uni.removeStorageSync('currentToken')
              uni.removeStorageSync('isServerLogin')
              uni.removeStorageSync('user_info')
              
              // 重置页面状态
              this.isLoggedIn = false
              this.userName = ''
              
              uni.showToast({
                title: '已退出登录',
                icon: 'success',
                duration: 1500
              })
              
              // 延迟重新加载页面，确保状态完全重置
              setTimeout(() => {
                uni.reLaunch({
                  url: '/pages/index/index'
                })
              }, 1500)
            } catch (error) {
              console.error('退出登录失败:', error)
              uni.showToast({
                title: '退出登录失败',
                icon: 'error'
              })
            }
          }
        }
      })
    },
    
    
    
    navigateToLogin() {
      uni.navigateTo({
        url: '/pages/auth/login/login'
      })
    },
    
    navigateToRegister() {
      uni.navigateTo({
        url: '/pages/auth/register/register'
      })
    },
    
    navigateToSettings() {
      uni.navigateTo({
        url: '/pages/settings/settings'
      })
    },
    
    
    navigateToAdmin() {
      uni.navigateTo({
        url: '/pages/admin/admin'
      })
    },
    
    navigateToTTS() {
      uni.navigateTo({
        url: '/pages/ai/voice/voice'
      })
    },

    navigateToEmoji() {
      uni.navigateTo({
        url: '/pages/ai/emoji/emoji'
      })
    },
    
    navigateToPetSettings() {
      uni.navigateTo({
        url: '/pages/pet/pet-settings'
      })
    },
    
    openDataSyncModal() {
      this.showDataSyncModal = true
    },
    
    closeDataSyncModal() {
      this.showDataSyncModal = false
    },
    
    onUserDataUpdated(updatedUser) {
      console.log('收到用户数据更新通知:', updatedUser)
      
      // 更新本地存储的用户信息
      uni.setStorageSync('currentUser', JSON.stringify(updatedUser))
      
      // 显示更新成功提示
      uni.showToast({
        title: '用户信息已更新',
        icon: 'success',
        duration: 1500
      })
      
      // 可以在这里触发页面刷新或其他更新逻辑
      // 例如：this.loadUserInfo()
    },
    
    navigateToLogs() {
      uni.navigateTo({
        url: '/pages/logs/logs'
      })
    },
    
    handleAvatarError() {
      // 头像加载失败时，清空头像URL
      this.userAvatar = ''
      console.log('头像加载失败，使用默认头像')
    },
    
    showAnnouncementDetail(announcement) {
      uni.showModal({
        title: announcement.title,
        content: announcement.content,
        showCancel: false,
        confirmText: '知道了'
      })
    },
    
    switchToAnnouncement(index) {
      this.currentAnnouncementIndex = index
      // 这里可以添加切换到指定公告的逻辑
      // 由于swiper组件比较复杂，这里暂时只更新指示点状态
    },
    
    startAnnouncementSync() {
      // 每6秒更新一次指示点状态，与swiper的自动播放同步
      setInterval(() => {
        this.currentAnnouncementIndex = (this.currentAnnouncementIndex + 1) % this.announcements.length
      }, 6000)
    },
    
    // 加载公告数据
    async loadAnnouncements() {
      try {
        // 检查服务器状态
        const serverStatus = appStateManager.getState("server")
        if (!serverStatus.isOnline) {
          console.log('服务器离线，使用默认公告')
          this.setDefaultAnnouncements()
          return
        }
        
        console.log('开始加载公告数据...')
        
        // 从后端获取已发布的公告
        const response = await apiService.getAdminAnnouncementList({
          page: 1,
          pageSize: 10,
          status: 'published' // 只获取已发布的公告
        })
        
        console.log('API响应:', response)
        
        if (response.code === 'SUCCESS' && response.data && response.data.announcements) {
          // 按发布时间倒序排列，最新的在前面
          this.announcements = response.data.announcements
            .sort((a, b) => new Date(b.publish_time || b.created_at) - new Date(a.publish_time || a.created_at))
            .map(announcement => ({
              id: announcement.id,
              title: announcement.title,
              content: announcement.content,
              type: announcement.type,
              date: announcement.publish_time || announcement.created_at
            }))
          
          console.log('成功加载公告:', this.announcements.length, '条')
          console.log('公告数据:', this.announcements)
        } else {
          console.log('获取公告失败，使用默认公告')
          console.log('响应数据:', response)
          this.setDefaultAnnouncements()
        }
      } catch (error) {
        console.error('加载公告失败:', error)
        this.setDefaultAnnouncements()
      }
    },
    
    // 设置默认公告（当服务器不可用时）
    setDefaultAnnouncements() {
      this.announcements = [
        {
          id: 1,
          title: '🎉 欢迎使用新版用户管理系统！',
          content: '我们很高兴为您介绍全新升级的用户管理系统，带来更好的用户体验和更多实用功能。',
          type: 'welcome',
          date: '2024-01-15'
        },
        {
          id: 2,
          title: '🎮 游戏中心新增多个精彩游戏',
          content: '游戏中心现已上线，包含荒岛求生、益智拼图等多种游戏类型，更多游戏正在开发中！',
          type: 'feature',
          date: '2024-01-10'
        },
        {
          id: 3,
          title: '⚙️ 系统设置功能全面升级',
          content: '全新的设置页面设计，更直观的功能分类，让您轻松管理个人信息和系统偏好。',
          type: 'update',
          date: '2024-01-08'
        }
      ]
    },
    

    
    updateServerStatusDisplay() {
      const status = appStateManager.getState("server")
      this.serverStatus = status.isOnline ? 'online' : 'offline'
      this.statusText = status.isOnline ? '服务器连接正常' : '服务器连接异常'
    },
    
    async refreshServerStatus() {
      if (this.isRefreshing) return
      
      this.isRefreshing = true
      try {
        await apiService.refreshServerStatus()
        this.updateServerStatusDisplay()
        const networkInfo = await apiService.getNetworkInfo()
        this.networkInfo = `网络: ${networkInfo.networkType}`
        
        uni.showToast({
          title: this.serverStatus === 'online' ? '服务器连接正常' : '服务器连接异常',
          icon: this.serverStatus === 'online' ? 'success' : 'none'
        })
      } catch (error) {
        console.error('刷新服务器状态失败:', error)
        uni.showToast({
          title: '刷新失败',
          icon: 'error'
        })
      } finally {
        this.isRefreshing = false
      }
    },
    
    setupServerStatusListener() {
      // 监听服务器状态变化
      apiService.onStatusChange((isOnline) => {
        // 只在状态真正改变时输出日志
        if (this.serverStatus !== (isOnline ? 'online' : 'offline')) {
          console.log('首页收到服务器状态变化:', isOnline ? '在线' : '离线')
        }
        this.updateServerStatusDisplay()
      })
    },
    
    removeServerStatusListener() {
      // 移除状态监听（如果需要的话）
      // 由于apiService使用数组存储回调，这里暂时不实现移除逻辑
    },
    
    initEnvironmentInfo() {
      this.envInfo = config.getEnvironmentInfo()
      // 只在开发环境显示环境信息
      this.showEnvInfo = this.envInfo.isDevelopment
      
      console.log('环境信息:', this.envInfo)
    },
    
    // 初始化桌面宠物
    initDesktopPet() {
      try {
        this.desktopPetData = desktopPetManager.getPetData()
        this.showDesktopPet = this.desktopPetData.isActive
        
        // 监听宠物数据更新
        desktopPetManager.on('pet-data-updated', (data) => {
          this.desktopPetData = data
          this.showDesktopPet = data.isActive
        })
        
        console.log('桌面宠物初始化成功:', this.desktopPetData.name)
      } catch (error) {
        console.error('桌面宠物初始化失败:', error)
      }
    },
    
    // 宠物数据更新回调
    onPetDataUpdated(data) {
      this.desktopPetData = data
      console.log('宠物数据已更新:', data)
    },
    
    // 清理资源
    cleanup() {
      // 清理定时器
      if (this.announcementTimer) {
        clearInterval(this.announcementTimer)
        this.announcementTimer = null
      }
      
      // 移除状态监听
      this.removeServerStatusListener()
    }
		}
	}
</script>

<style scoped>
.home-container {
  /* 使用calc计算实际可用高度：100vh - 导航栏(44px约88rpx) - TabBar(50px约100rpx) */
  min-height: calc(100vh - 188rpx);
  height: auto;
  background: linear-gradient(180deg, #f7f8fc 0%, #eef1f7 100%);
  padding: 20rpx;
  padding-bottom: 40rpx;
  box-sizing: border-box;
}

/* ========== 服务器状态 - 紧凑版 ========== */
.server-status-compact {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12rpx 20rpx;
  background: rgba(255, 255, 255, 0.95);
  margin-bottom: 16rpx;
  border-radius: 12rpx;
  box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.04);
  backdrop-filter: blur(10rpx);
}

.status-left {
  display: flex;
  align-items: center;
  gap: 10rpx;
}

.status-dot {
  width: 12rpx;
  height: 12rpx;
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}

.status-dot.online {
  background-color: #10b981;
  box-shadow: 0 0 8rpx rgba(16, 185, 129, 0.4);
}

.status-dot.offline {
  background-color: #ef4444;
  box-shadow: 0 0 8rpx rgba(239, 68, 68, 0.4);
}

.status-dot.checking {
  background-color: #f59e0b;
  box-shadow: 0 0 8rpx rgba(245, 158, 11, 0.4);
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.9); }
}

.status-label {
  font-size: 22rpx;
  color: #374151;
  font-weight: 500;
}

.status-right {
  display: flex;
  align-items: center;
  gap: 12rpx;
}

.network-label {
  font-size: 20rpx;
  color: #9ca3af;
}

.refresh-icon {
  width: 48rpx;
  height: 48rpx;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 50%;
  transition: all 0.3s ease;
}

.refresh-icon.refreshing {
  animation: rotate 1s linear infinite;
}

@keyframes rotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.icon-text {
  font-size: 24rpx;
}

.env-info-compact {
  background: rgba(99, 102, 241, 0.06);
  border: 1rpx solid rgba(99, 102, 241, 0.15);
  border-radius: 10rpx;
  padding: 8rpx 16rpx;
  margin-bottom: 16rpx;
  text-align: center;
}

.env-label {
  font-size: 20rpx;
  color: #6366f1;
  font-weight: 500;
}



/* ========== 用户信息卡片 - 增强版 ========== */
.user-info-card {
  position: relative;
  background: white;
  border-radius: 24rpx;
  padding: 32rpx;
  margin-bottom: 24rpx;
  box-shadow: 0 8rpx 24rpx rgba(0, 0, 0, 0.08);
  overflow: hidden;
  transition: all 0.3s ease;
}

.user-info-card:active {
  transform: translateY(-2rpx);
  box-shadow: 0 12rpx 32rpx rgba(0, 0, 0, 0.12);
}

.card-background {
  position: absolute;
  top: 0;
  right: 0;
  width: 200rpx;
  height: 200rpx;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
  border-radius: 50%;
  transform: translate(50%, -50%);
}

.user-main-info {
  position: relative;
  display: flex;
  align-items: center;
  gap: 24rpx;
  z-index: 1;
}

.avatar-wrapper {
  position: relative;
}

.avatar-ring {
  position: absolute;
  top: -6rpx;
  left: -6rpx;
  right: -6rpx;
  bottom: -6rpx;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  opacity: 0.2;
  animation: ring-pulse 3s ease-in-out infinite;
}

@keyframes ring-pulse {
  0%, 100% { transform: scale(1); opacity: 0.2; }
  50% { transform: scale(1.1); opacity: 0.3; }
}

.user-avatar-enhanced {
  width: 100rpx;
  height: 100rpx;
  border-radius: 50%;
  border: 4rpx solid white;
  box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
}

.default-avatar-enhanced {
  width: 100rpx;
  height: 100rpx;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 4rpx solid white;
  box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
}

.avatar-text-large {
  color: white;
  font-size: 40rpx;
  font-weight: bold;
}

.user-details {
  flex: 1;
}

.greeting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10rpx;
}

.greeting-title {
  font-size: 32rpx;
  font-weight: bold;
  color: #1f2937;
  letter-spacing: 0.5rpx;
}

.greeting-subtitle-new {
  display: block;
  font-size: 24rpx;
  color: #9ca3af;
  margin-top: 4rpx;
}

/* 管理员徽章 */
.admin-badge {
  display: flex;
  align-items: center;
  gap: 6rpx;
  padding: 8rpx 14rpx;
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border-radius: 16rpx;
  border: 1rpx solid #fbbf24;
  transition: all 0.2s ease;
}

.admin-badge:active {
  transform: scale(0.95);
}

.badge-icon {
  font-size: 20rpx;
  animation: sparkle 2s ease-in-out infinite;
}

@keyframes sparkle {
  0%, 100% { transform: rotate(0deg) scale(1); }
  25% { transform: rotate(-15deg) scale(1.1); }
  75% { transform: rotate(15deg) scale(1.1); }
}

.badge-text {
  font-size: 20rpx;
  color: #d97706;
  font-weight: bold;
}

/* 欢迎内容样式 */
.welcome-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: white;
  border-radius: 16rpx;
  padding: 30rpx;
  margin-bottom: 20rpx;
  box-shadow: 0 6rpx 18rpx rgba(0, 0, 0, 0.06);
}

.welcome-info {
  flex: 1;
}

.welcome-title {
  display: block;
  font-size: 32rpx;
  font-weight: bold;
  color: #1f2937;
  margin-bottom: 8rpx;
}

.welcome-subtitle {
  display: block;
  font-size: 24rpx;
  color: #6b7280;
}

.welcome-actions {
  display: flex;
  gap: 16rpx;
}

/* ========== 功能中心标题 - 优化版 ========== */
.function-center-title {
  text-align: center;
  margin-bottom: 28rpx;
  padding: 0 20rpx;
}

.title-text {
  display: block;
  font-size: 36rpx;
  font-weight: bold;
  color: #1f2937;
  margin-bottom: 10rpx;
  letter-spacing: 1rpx;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle-text {
  display: block;
  font-size: 24rpx;
  color: #9ca3af;
  font-weight: 400;
}

/* 按钮样式 */
.login-btn, .register-btn {
  padding: 14rpx 22rpx;
  border: none;
  border-radius: 12rpx;
  font-size: 24rpx;
  font-weight: bold;
  min-width: 96rpx;
}

.login-btn {
  background: #6366f1;
  color: white;
  box-shadow: 0 4rpx 12rpx rgba(99, 102, 241, 0.25);
}

.register-btn {
  background: white;
  color: #4f46e5;
  border: 2rpx solid #c7d2fe;
}

/* ========== 公告横幅 - 优化版 ========== */
.announcement-section {
  margin-bottom: 24rpx;
}

.announcement-banner {
  background: linear-gradient(135deg, #f59e0b 0%, #f97316 100%);
  border-radius: 18rpx;
  overflow: hidden;
  box-shadow: 0 8rpx 24rpx rgba(249, 115, 22, 0.3);
  position: relative;
}

.announcement-banner::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, 
    rgba(255, 255, 255, 0.1) 0%, 
    rgba(255, 255, 255, 0) 50%, 
    rgba(255, 255, 255, 0.1) 100%);
  animation: shimmer 3s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.banner-content {
  display: flex;
  align-items: center;
  padding: 18rpx 20rpx;
  position: relative;
  z-index: 1;
}

.banner-icon {
  font-size: 36rpx;
  margin-right: 16rpx;
  animation: bell-ring 2s ease-in-out infinite;
}

@keyframes bell-ring {
  0%, 100% { transform: rotate(0deg); }
  10%, 30% { transform: rotate(-10deg); }
  20%, 40% { transform: rotate(10deg); }
}

.announcement-swiper {
  flex: 1;
  height: 44rpx;
}

.announcement-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

.announcement-text {
  color: white;
  font-size: 26rpx;
  font-weight: 600;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.1);
}

.announcement-arrow {
  color: white;
  font-size: 28rpx;
  margin-left: 16rpx;
  opacity: 0.9;
  font-weight: bold;
}

/* 自定义指示点样式 */
.announcement-indicators {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 14rpx 0;
  gap: 10rpx;
}

.indicator-dot {
  width: 14rpx;
  height: 14rpx;
  border-radius: 50%;
  background-color: #e5e7eb;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.indicator-dot.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  transform: scale(1.4);
  box-shadow: 0 2rpx 8rpx rgba(102, 126, 234, 0.4);
}

.welcome-content {
  text-align: center;
  margin-bottom: 40rpx;
  padding: 40rpx;
  background: white;
  border-radius: 16rpx;
  box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
}

.welcome-title {
		font-size: 36rpx;
  font-weight: bold;
  color: #333;
  display: block;
  margin-bottom: 16rpx;
}

.welcome-subtitle {
  font-size: 24rpx;
  color: #666;
  display: block;
  margin-bottom: 30rpx;
  line-height: 1.5;
}

/* ========== 功能卡片网格 - 增强版 ========== */
.function-grid-enhanced {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20rpx;
  margin-bottom: 40rpx;
}

.function-card {
  position: relative;
  background: white;
  border-radius: 20rpx;
  padding: 0;
  overflow: hidden;
  box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.06);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.function-card:active {
  transform: translateY(-4rpx) scale(0.98);
  box-shadow: 0 12rpx 28rpx rgba(0, 0, 0, 0.12);
}

.card-gradient {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 80rpx;
  opacity: 0.15;
  transition: opacity 0.3s ease;
}

.function-card:active .card-gradient {
  opacity: 0.25;
}

.gradient-purple {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.gradient-blue {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.gradient-cyan {
  background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
}

.gradient-orange {
  background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
}

.gradient-pink {
  background: linear-gradient(135deg, #fccb90 0%, #d57eeb 100%);
}

.gradient-green {
  background: linear-gradient(135deg, #84fab0 0%, #8fd3f4 100%);
}

.card-content {
  position: relative;
  padding: 36rpx 24rpx 28rpx;
  text-align: center;
  z-index: 1;
}

.function-icon-large {
  font-size: 56rpx;
  display: block;
  margin-bottom: 16rpx;
  filter: drop-shadow(0 4rpx 8rpx rgba(0, 0, 0, 0.1));
  animation: icon-float 3s ease-in-out infinite;
}

@keyframes icon-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6rpx); }
}

.function-card:nth-child(1) .function-icon-large { animation-delay: 0s; }
.function-card:nth-child(2) .function-icon-large { animation-delay: 0.2s; }
.function-card:nth-child(3) .function-icon-large { animation-delay: 0.4s; }
.function-card:nth-child(4) .function-icon-large { animation-delay: 0.6s; }
.function-card:nth-child(5) .function-icon-large { animation-delay: 0.8s; }
.function-card:nth-child(6) .function-icon-large { animation-delay: 1s; }

.function-name-bold {
  font-size: 28rpx;
  font-weight: bold;
  color: #1f2937;
  display: block;
  margin-bottom: 8rpx;
  letter-spacing: 0.5rpx;
}

.function-desc-new {
  font-size: 22rpx;
  color: #9ca3af;
  line-height: 1.4;
  display: block;
}



</style>
